package br.sales.view.bean;

import java.io.Serializable;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.RequestScoped;

import br.sales.entity.UserEntity;


@RequestScoped
@ManagedBean(name="permissionBean")
public class PermissionBean implements Serializable {

	private static final long serialVersionUID = 1L;
	
	@ManagedProperty(value="#{mainBean}")
	private MainBean mainBean;
	
	public PermissionBean() {
	}
	
	public boolean isLogged(){
		return mainBean.getLoggedUser() != null;
	}
	
	public boolean isAdmin(){
		return isLogged() && mainBean.getLoggedUser().getType() == UserEntity.ADMIN;
	}

	public MainBean getMainBean() {
		return mainBean;
	}

	public void setMainBean(MainBean mainBean) {
		this.mainBean = mainBean;
	}
	
}

